from build_in import os

basedir = os.path.abspath(os.path.dirname(__file__))


class BaseConfig:
    """配置基本类"""
    APP_NAME = "blog"
    API_VERSION = "v1"
    DEBUG = False
    LOG_LEVEL = "DEBUG"
    PROJECT_NAME = "my-python-app"


class DevConfig(BaseConfig):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or \
                              'mysql+pymysql://root:123456@127.0.0.1/p3_blog_test?charset=utf8'


class UatConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URI') or \
                              'sqlite:///' + os.path.join(basedir, 'data-test.sqlite')


class ProConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or \
                              'sqlite:///' + os.path.join(basedir, 'data.sqlite')


config = {
    'development': DevConfig,
    'testing': UatConfig,
    'production': ProConfig,
    'default': DevConfig
}


def get_config():
    return config[os.getenv('FLASK_CONFIG') or 'default']